<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let s1 = Symbol()
    let s2 = Symbol()
    // false
    console.log('s1 === s2?', s1 === s2)
    // false
    console.log('s1 == s2?', s1 == s2)
    console.log('s1.toString()', s1.toString())
    console.log('s2.toString()', s2.toString())


    // 添加到对象上
    let obj = {
      toString() {
        return 'abc'
      }
    }
    let s3 = Symbol(obj)
    console.log('s3.toString(): ', s3.toString())

    console.log('s3.description', s3.description)



    let log = {}
    log.levels = {
      DEBUG: Symbol('debug'),
      INFO: Symbol('info'),
      WARN: Symbol('warn')
    }
  </script>

  <!-- 内置 Symbol  -->
  <script>
    // Symbol.hasInstance
    class MyClass {
      constructor() {
      }
      [Symbol.hasInstance](arr) {
        console.log(arr)
        return arr instanceof Array
      }
    }
    console.log([1, 2, 3] instanceof new MyClass())

  </script>
</body>
</html>